
const db = wx.cloud.database()
const collectionName = 'address'

export default { 
  async addAdress(data){
    let res = await db.collection(collectionName).add({
      data: data
    })
  },
  updateAddres: async function(data){
    var _id = data._id
    delete data._id


    var res = await db.collection(collectionName).doc(_id).update({
      data: data
    })
    return res
  },

  getAddress: async function({prizeId}){

    let res = await db.collection(collectionName).aggregate()
        .match({
          prizeId
        })
        .end()

  
    return res.list
  },

}